package com.windaka.elements.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.DefaultTokenServices;
import org.springframework.security.oauth2.provider.token.TokenStore;

import javax.annotation.Resource;


/**
 * 配置 TokenService
 * 配置 token有效期
 * 还可以配置 refresh token有效等等等
 * @author song
 * @date 9:27 下午 2021/11/13
 * @param 
 * @return 
 * @other
**/
@Configuration
public class TokenServiceConfig {

    @Resource
    private TokenStore tokenStore;

    @Bean
    public DefaultTokenServices tokenService() {
        DefaultTokenServices tokenServices = new DefaultTokenServices();
        // 配置token存储
        tokenServices.setTokenStore(tokenStore);
        // 配置token有效时间 60秒
        // 60秒考虑到 只登录没有访问
        tokenServices.setAccessTokenValiditySeconds(180);
        return tokenServices;
    }
    
}
